package reflect;

import java.util.Random;

/**
 * @Author Zhouchb
 * @Create 2021-10-2021/10/24 :16:29
 * @Description
 */
public class DynamicsTest {
    public static void main(String[] args) throws Exception {
        int num = new Random().nextInt(3);
        System.out.println(num);
        String classPath = "";
        switch (num){
            case 0:
               classPath="java.util.Date";
                break;
            case 1:
                classPath ="java.lang.Object";
                break;
            case 2:
                System.out.println("********");
               classPath="reflect.Persion";
                break;
        }
        Object instant = getInstant(classPath);
        System.out.println(instant);
    }
    public static Object getInstant(String classPath) throws Exception {
        Class<?> clazz = Class.forName(classPath);
        return clazz.newInstance();
    }
}
